package com.ctshk.rpc.goods.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.ctshk.rpc.goods.base.CustomBaseMapper;
import com.ctshk.rpc.goods.entity.CommodityCostAttribute;

/**
 * <p>
 * 商品成本表属性 Mapper 接口
 * </p>
 *
 * @author 姜斌文
 * @since 2021-04-13
 */
public interface CommodityCostAttributeMapper extends CustomBaseMapper<CommodityCostAttribute> {

	@Select("SELECT t.id,t.commodity_attribute_id,t.commodity_id,t.specifications_attribute_one_id,"
			+ "t.specifications_attribute_one_name,t.specifications_attribute_two_id,t.specifications_attribute_two_name,"
			+ "t.gmt_create,t.create_id,t.gmt_modified,t.modified_id,t.is_deleted "
			+ "FROM t_commodity_cost_attribute t "
			+ "WHERE  t.is_deleted = 0 AND "
			+ "t.commodity_id = #{commodityId} AND t.commodity_attribute_id = #{commodityAttributeId}")
	List<CommodityCostAttribute> findCostAttributeByCommodityIdAndAttributeId(
			@Param("commodityId")Long commodityId, @Param("commodityAttributeId")Long commodityAttributeId);

	/**
	 * 属性id和商品id查询商品成本
	 * @param commodityAttributeId	属性ID
	 * @param commodityId			商品ID
	 * @return
	 */
	@Select("SELECT * FROM `ctshk-goods`.t_commodity_cost_attribute     " +
					"WHERE (commodity_attribute_id = #{commodityAttributeId} AND commodity_id = #{commodityId})")
    List<CommodityCostAttribute> selectListByCostIdAndCommodityId(@Param("commodityAttributeId") Long commodityAttributeId, @Param("commodityId") Long commodityId);
}
